package top.houry.im.client.enums;

import lombok.Getter;
import top.houry.im.client.handler.impl.*;

import java.util.Arrays;


public enum ImClientMsgTypeProcessorEnum {

    EMPTY_MSG_TYPE("server.empty.req", new ImClientEmptyMsgHandlerImpl()),
    HEART_BEAT_MSG_TYPE("server.heartbeat.req", new ImClientHeartBeatHandlerImpl()),
    LOGIN_RESP_MSG_TYPE("server.login.resp", new ImClientLoginHandlerImpl()),
    SERVER_CHAT_MSG_RECV("server.chat.msg.recv", new ImClientMsgRecvServiceImpl()),
    CLIENT_FRIENDS_REQ("server.friends.resp", new ImClientFriendsRecvServiceImpl()),

    ;


    public static ImClientMsgTypeProcessorEnum findByMsgType(String msgType) {
        return Arrays.stream(ImClientMsgTypeProcessorEnum.values()).filter(msgEnum -> msgType.equals(msgEnum.msgType)).findFirst().orElse(EMPTY_MSG_TYPE);
    }

    ImClientMsgTypeProcessorEnum(String msgType, Object clazz) {
        this.clazz = clazz;
        this.msgType = msgType;
    }


    @Getter
    String msgType;

    @Getter
    Object clazz;

}
